hvm emulate: Correctly probe when we are in 64-bit mode and set
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 3 Mar 2008 15:19:39 +0000 (15:19 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 3 Mar 2008 15:19:39 +0000 (15:19 +0000)
address-size default appropriately.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/arch/x86/hvm/emulate.c
xen/arch/x86/mm/shadow/common.c

index 7ba9b703ded1dd0658cf83e6d7a7d886e48919e4..9c1a2daeb6026e87607dc89b5da4af3a6e2135c1 100644 (file)
@@ -673,14 +673,23 @@ int hvm_emulate_one(
     struct hvm_emulate_ctxt *hvmemul_ctxt)
 {
     struct cpu_user_regs *regs = hvmemul_ctxt->ctxt.regs;
+    struct vcpu *curr = current;
     uint32_t new_intr_shadow;
     unsigned long addr;
     int rc;
 
-    hvmemul_ctxt->ctxt.addr_size =
-        hvmemul_ctxt->seg_reg[x86_seg_cs].attr.fields.db ? 32 : 16;
-    hvmemul_ctxt->ctxt.sp_size =
-        hvmemul_ctxt->seg_reg[x86_seg_ss].attr.fields.db ? 32 : 16;
+    if ( hvm_long_mode_enabled(curr) &&
+         hvmemul_ctxt->seg_reg[x86_seg_cs].attr.fields.l )
+    {
+        hvmemul_ctxt->ctxt.addr_size = hvmemul_ctxt->ctxt.sp_size = 64;
+    }
+    else
+    {
+        hvmemul_ctxt->ctxt.addr_size =
+            hvmemul_ctxt->seg_reg[x86_seg_cs].attr.fields.db ? 32 : 16;
+        hvmemul_ctxt->ctxt.sp_size =
+            hvmemul_ctxt->seg_reg[x86_seg_ss].attr.fields.db ? 32 : 16;
+    }
 
     hvmemul_ctxt->insn_buf_eip = regs->eip;
     hvmemul_ctxt->insn_buf_bytes =
@@ -715,11 +724,11 @@ int hvm_emulate_one(
     if ( hvmemul_ctxt->intr_shadow != new_intr_shadow )
     {
         hvmemul_ctxt->intr_shadow = new_intr_shadow;
-        hvm_funcs.set_interrupt_shadow(current, new_intr_shadow);
+        hvm_funcs.set_interrupt_shadow(curr, new_intr_shadow);
     }
 
     if ( hvmemul_ctxt->ctxt.retire.flags.hlt &&
-         !hvm_local_events_need_delivery(current) )
+         !hvm_local_events_need_delivery(curr) )
     {
         hvm_hlt(regs->eflags);
     }
index 240d9100f0505c4fd639dc089d52c4e7823f396c..fdb1d0e4aafdfc965128fe63512f5c5dd8686d56 100644 (file)
@@ -402,10 +402,6 @@ struct x86_emulate_ops *shadow_init_emulation(
     {
         sh_ctxt->ctxt.addr_size = sh_ctxt->ctxt.sp_size = 64;
     }
-    else if ( regs->eflags & X86_EFLAGS_VM )
-    {
-        sh_ctxt->ctxt.addr_size = sh_ctxt->ctxt.sp_size = 16;
-    }
     else
     {
         sreg = hvm_get_seg_reg(x86_seg_ss, sh_ctxt);